/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package domain;

import domain.exceptions.CannotFlagSquareException;
import domain.exceptions.CannotPlaceAgentHereException;

/**
 *
 * @author shaigi
 */
public class SquareFree extends Square{
    
    public SquareFree(int row, int column){
        setAgent(null);
        setRow(row);
        setColumn(column);
        try {
			setFlag(null);
		} catch (CannotFlagSquareException e) {
			e.printStackTrace();
		}
    }
    
    public SquareFree(SquareFree other){
    	setAgent(null);
        setRow(other.getRow());
        setColumn(other.getColumn());
        try {
        	if(other.isContainFlag()){
        		setFlag(new Flag (other.getFlag()));
        		this.getFlag().setSquare(this);
        	}
        	else
        		setFlag(null);
		} catch (CannotFlagSquareException e) {
			e.printStackTrace();
		}
    }
    

	@Override
    public String toString(){
        return "Free Square " + toStringLocation();
    }

    public void placeAgent(Agent agent) throws CannotPlaceAgentHereException{
    	if (isThereAgentHere())
    		throw new CannotPlaceAgentHereException();
//        try {
//            agent.getSquare().removeAgent();
//        } catch (Exception ex) {
//            Debug.println(ex.getMessage());
//        }
        setAgent(agent);
    }
    
}
